package resources;

import java.util.ArrayList;
import java.util.List;

import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Request;
import javax.ws.rs.core.UriInfo;

import resources.lectureRoom.LectureRoomsRes;

import dao.LectureRoomDAO;
import dao.Linker;

import model.lectureRoom.Building;

@Path("/lectureroom")
public class LectureRoomRes 
{
	@Context
	UriInfo uriInfo;
	
	@Context
	Request request;
	
	@GET
	@Produces(MediaType.TEXT_XML)
	public List<Building> getDataBrowser() 
	{
		Linker.sort();
		
		List<Building> buildings = new ArrayList<Building>();
		buildings.addAll( LectureRoomDAO.getBuildingsCP().values() );
		return buildings; 
	}
	
	@GET
	@Produces(MediaType.APPLICATION_JSON)
	public List<Building> getDataBrowserJSON() 
	{
		return getDataBrowser(); 
	}
	
	@GET
	@Produces(MediaType.APPLICATION_XHTML_XML)
	public List<Building> getDataBrowserXHTML() 
	{
		return getDataBrowser(); 
	}
	
	@GET
	@Produces(MediaType.APPLICATION_XML)
	public List<Building> getDataBrowserXML() 
	{
		return getDataBrowser(); 
	}

	@Path("{lecturerooms}")
	public LectureRoomsRes getSubData(@PathParam("lecturerooms") String id) 
	{
		return new LectureRoomsRes(uriInfo, request, id);
	}
}